﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Yipusoft.BaseDoc.Model;

public partial class Task_JobProgress : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
            Bind();

    }

    private void Bind()
    {
        rptList.DataSource = Yipusoft.BaseDoc.BLL.Progress.GetList("ItemLevel=0");
        rptList.DataBind();
    }
    public string GetFullName(object objID)
    {
        if (objID == null || objID == DBNull.Value)
            return "";
        List<ProgressInfo> list = Yipusoft.BaseDoc.BLL.Progress.GetList(" ParentID='" + objID + "'");
        if (list == null)
            return "";

        string ReturnStr = string.Empty;
        int i = 0;
        foreach (ProgressInfo info in list)
        {
            ReturnStr += info.FullName;
            i++;
            if (i % 2 == 0)
                ReturnStr += "<br/>";

        }

        return ReturnStr;

    }

/// <summary>
/// 
/// </summary>
/// <param name="objID"></param>
/// <param name="Flag">0为总数，1为已建成，2为未建成，3应建成</param>
/// <returns></returns>
    public int GetSum(object objID,int Flag)
    {
        if (objID == null || objID == DBNull.Value)
            return 0;
        string where = string.Empty;
        if (Flag == 0)
            where = "And 1=1";
        else if (Flag == 1)
            where = "And IsPass='1'";
        else if (Flag == 2)
            where = "And IsPass='0'";
        else if(Flag==3)
            where = " And CreateYear=2009";
        

        List<ProgressInfo> list = Yipusoft.BaseDoc.BLL.Progress.GetList(" ParentID='" + objID + "'"+where);
        if (list == null)
            return 0;

        return list.Count();
    }

    /// <summary>
    /// 应建成
    /// </summary>
    /// <param name="objID"></param>
    /// <returns></returns>
    public string GetCreateDepartment(object objID)
    {
        if (objID == null || objID == DBNull.Value)
            return "";
        List<ProgressInfo> list = Yipusoft.BaseDoc.BLL.Progress.GetList(" ParentID='" + objID + "' and CreateYear=2009");
        if (list == null)
            return "";

        string ReturnStr = string.Empty;
        int i = 0;
        foreach (ProgressInfo info in list)
        {
            ReturnStr += info.FullName;
            i++;
            if (i % 2 == 0)
                ReturnStr += "<br/>";

        }

        return ReturnStr;
    }

    /// <summary>
    /// 已建成
    /// </summary>
    /// <param name="objID"></param>
    /// <returns></returns>
    public string GetCreateDepartmentOK(object objID)
    {
        if (objID == null || objID == DBNull.Value)
            return "";
        List<ProgressInfo> list = Yipusoft.BaseDoc.BLL.Progress.GetList(" ParentID='" + objID + "' and CreateYear=2009 And IsPass='1'");
        if (list == null)
            return "";

        string ReturnStr = string.Empty;
        int i = 0;
        foreach (ProgressInfo info in list)
        {
            ReturnStr += info.FullName;
            i++;
            if (i % 2 == 0)
                ReturnStr += "<br/>";

        }

        return ReturnStr;
    }

    /// <summary>
    /// 未建成
    /// </summary>
    /// <param name="objID"></param>
    /// <returns></returns>
    public string GetCreateDepartmentNO(object objID)
    {
        if (objID == null || objID == DBNull.Value)
            return "";
        List<ProgressInfo> list = Yipusoft.BaseDoc.BLL.Progress.GetList(" ParentID='" + objID + "' and CreateYear=2009 And IsPass='0'");
        if (list == null)
            return "";

        string ReturnStr = string.Empty;
        int i = 0;
        foreach (ProgressInfo info in list)
        {
            ReturnStr += info.FullName;
            i++;
            if (i % 2 == 0)
                ReturnStr += "<br/>";

        }

        return ReturnStr;
    }
    protected void rptList_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        Label lblID = e.Item.FindControl("lblDepartmentID") as Label;
        Repeater rpt = e.Item.FindControl("rptList2") as Repeater;
        if (lblID == null||rpt==null)
            return;

        rpt.DataSource = Yipusoft.BaseDoc.BLL.Progress.GetList("ParentID='" + lblID.Text + "'");
        rpt.DataBind();
    }
}
